package cocktail

import "fmt"

type sortType interface {
	int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64 | uintptr | float32 | float64 | string
}

func Sort[T sortType](arr []T) {
	count := 0
	for i := 0; i < len(arr)/2; i++ {
		fmt.Println("-------------------")
		sorted := true
		for j := i; j < len(arr)-i-1; j++ {
			if arr[j] > arr[j+1] {
				arr[j], arr[j+1] = arr[j+1], arr[j]
				sorted = false
				count++
			}
		}
		if sorted {
			break
		}

		sorted = true
		for j := len(arr) - 1 - i; j > i; j-- {
			if arr[j] < arr[j-1] {
				arr[j], arr[j-1] = arr[j-1], arr[j]
				sorted = false
				count++
			}
		}
		if sorted {
			break
		}
	}
	fmt.Println(count)

}
